//
//  MYGPositionManager.swift
//  MYGrow
//
//  Created by 小火科技 on 2024/3/19.
//

import UIKit
import CoreLocation
import BMKLocationKit
class MYGPositionManager: NSObject {
    static let shared: MYGPositionManager = MYGPositionManager()
    
    func startLocation(completeBlock: ((_ coor: CLLocationCoordinate2D?, _ city: String?)->Void)? = nil) {
        locationManager.requestLocation(withReGeocode: true, withNetworkState: true) { location, state, error in
            if let error = error {
                print("定位失败：\(error)")
                return
            }
            
            let coor = location?.location?.coordinate
            let city = location?.rgcData?.city
            completeBlock?(coor, city)
        }
    }
    
    private lazy var locationManager: BMKLocationManager = {
        let manager = BMKLocationManager()
        manager.delegate = self
    
        return manager
    }()
}

extension MYGPositionManager: BMKLocationManagerDelegate {
    
}
